package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysFiles;
import com.ruoyi.system.service.ISysFilesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 文件Controller
 *
 * @author zls
 * @date 2020-11-07
 */
@Controller
@RequestMapping("/system/files")
public class SysFilesController extends BaseController
{
    private String prefix = "system/files";

    @Autowired
    private ISysFilesService sysFilesService;

    @RequiresPermissions("system:files:view")
    @GetMapping()
    public String files()
    {
        return prefix + "/files";
    }

    /**
     * 查询文件列表
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public List<SysFiles> list(SysFiles sysFiles)
    {
       return sysFilesService.selectSysFilesList(sysFiles);
    }
    /**
     * 删除文件
     */
    @Log(title = "文件", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String key)
    {
        return toAjax(sysFilesService.deleteSysFilesByIds(key));
    }
}
